<template>
<div>
  <m-song-table :data="tableData" :height="660"></m-song-table>
</div>
</template>

<script>
import musicApi from '@/musicApi/apis/songs'
import music from "@/until/js/music";
import songTable from "@/components/aplayer/songTable";
export default {
  name: "song",
  props:["keywords","type"],
  components:{
    "m-song-table":songTable
  },
  data() {
    return {
      tableData: []
    }
  },
  mounted() {
    this.getMusic(this.keywords,this.type)
  },
  methods:{
      //获取搜索单曲音乐信息
    getMusic(keywords,type){
        musicApi.getSearch(keywords,type).then(res=>{
          this.tableData=music.getSongsData(res.data.result.songs)
          //将每日新歌存入播放列表
          this.$store.commit('SET_Song_List',JSON.stringify(this.tableData));
        })
      },
    //获取所在行的歌曲信息
    async getSongId(row){
      this.$store.commit('SET_Song_Id',row);
    },
  },
  computed:{
    WatchKeyword(){
     return this.keywords
    }
  },
  watch:{
    WatchKeyword:{
      handler(newKey){
        this.getMusic(newKey,this.type)
      }
    }
  }
}
</script>

<style scoped>

</style>